package org.neptune.service.service.impl;

import com.google.common.collect.Maps;
import org.neptune.common.util.DateUtil;
import org.neptune.service.service.SystemInfo;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.Properties;

/**
 * @author lwl
 * @date 2020/2/9 11:19 上午
 */
@Service
public class SystemInfoImpl implements SystemInfo {

	@Override
	public Map<String, Object> querySystemInfo() {
		Map<String, Object> result = Maps.newHashMap();

		Runtime run = Runtime.getRuntime();
		Properties props = System.getProperties();

		result.put("totalMemory",run.totalMemory()/(1024*1024)+"M");
		result.put("freeMemory",run.freeMemory()/(1024*1024)+"M");
		result.put("javaVersion",props.getProperty("java.version"));
		result.put("osName",props.getProperty("os.name"));
		result.put("nowTime", DateUtil.getNowDayStr());

		return result;
	}
}
